﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;  

public partial class Players_list : System.Web.UI.Page
{
    public int Total_Players = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            sel_tour.DataSource = Tournament.getAvailableTournaments();
            sel_tour.DataTextField = "Tournament_Name";
            sel_tour.DataValueField = "Pk_Tournament";
            sel_tour.DataBind();

            if (sel_tour.Items.Count > 0)
            {
                playerlist.DataSource = Player.GetPlayersByTournament(Int16.Parse(sel_tour.SelectedValue));

                playerlist.DataBind();
                Total_Players = playerlist.Rows.Count;
            }
            else {
                Total_Players = 0;
            }
        }
   

        
    }

    
    protected void sel_tour_SelectedIndexChanged1(object sender, EventArgs e)
    {
        playerlist.DataSource = Player.GetPlayersByTournament(Int16.Parse(sel_tour.SelectedValue));
        playerlist.DataBind();
        Total_Players = playerlist.Rows.Count;
    }
    protected string Getimage(string p_param) {
        return "<img src=\"img/player_flags/b"+ p_param + ".png\"/>" ;
    }


}
